home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJSRC106.ARJ / ATI.ASM < prev    next >
Assembly Source File  |  1991-07-20  |  5KB  |  268 lines

  1. ; This is file ATIVGA.ASM
  2. ;
  3. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. ;
  5. ; This file is distributed under the terms listed in the document
  6. ; "copying.dj", available from DJ Delorie at the address above.
  7. ; A copy of "copying.dj" should accompany this file; if not, a copy
  8. ; should be available from where this file was obtained.  This file
  9. ; may not be distributed without a verbatim copy of "copying.dj".
  10. ;
  11. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. ;
  14. ;
  15. ; Modify for the ATI VGA WONDER
  16. ; by Luc Bussieres, bussiere@dmi.usherb.ca
  17. ; University of Sherbrooke
  18. ; March 9th, 1991
  19. ;
  20. ; Version revised by Patrick Daloze, daloze@iro.umontreal.ca
  21. ; University of Montreal
  22. ; Juilly, 4th, 1991
  23. ;
  24.  
  25. cseg    segment    byte public 'code'
  26.     assume    cs:cseg, ds:cseg, es:cseg, ss:nothing
  27.  
  28.     dw    offset init_routine
  29.     dw    offset paging_routine
  30.     dw     1       ; set to 1 if separate read & write windows or
  31.             ; only 64K of video RAM (ie: no paging)
  32.  
  33. def_tw    dw    80    ; filled in by go32 if GO32 env. var. is set
  34. def_th     dw    25
  35. def_gw    dw     640
  36. def_gh     dw     480
  37. IO_Add  dw      0
  38.  
  39. ;--------------------------------------------------------------------------
  40. ; Entry: AX=mode selection
  41. ;        0=80x25 text
  42. ;        1=default text
  43. ;        2=text CX cols by DX rows
  44. ;        3=biggest text
  45. ;        4=320x200 graphics
  46. ;        5=default graphics
  47. ;        6=graphics CX width by DX height
  48. ;        7=biggest non-interlaced graphics
  49. ;        8=biggest graphics
  50. ;
  51. ; NOTE: This runs in real mode, but don't mess with the segment registers.
  52. ;       For mode 5 to 8 (640x480 or over): only for ATI Version 2 or more
  53. ;       (separate read and write planing).
  54. ;
  55. ; Exit:  CX=width (in pixels or characters)
  56. ;        DX=height
  57.  
  58. init_table    label    word
  59.     dw    offset init_0
  60.     dw    offset init_1
  61.     dw    offset init_2
  62.     dw    offset init_3
  63.     dw    offset init_4
  64.     dw    offset init_5
  65.     dw    offset init_6
  66.     dw    offset init_7
  67.     dw    offset init_8
  68.  
  69. init_routine    proc    far
  70.     cmp    ax,8
  71.     jbe    valid_req
  72.     ret
  73. valid_req:
  74.     shl    ax,1
  75.     mov    bx,ax
  76.     jmp    init_table[bx]
  77.  
  78. init_0: ; 80x25 text
  79.     mov    ax,3
  80.     int    10h
  81.     mov    cx,80
  82.     mov    dx,25
  83.     ret
  84.  
  85. init_1: ; default text
  86.     mov    cx,def_tw
  87.     mov    dx,def_th
  88.     jmp    init_2
  89.  
  90. init_2_table    label    word
  91.     dw    01h, 40, 25
  92.     dw    03h, 80, 25
  93.     dw      23h, 132, 25
  94.     dw      33h, 132, 44
  95. init_2_tend    label    word
  96.  
  97. init_2: ; CX*DX text
  98.     mov    si,offset init_2_table
  99. init_2a:
  100.     cmp    [si+2],cx
  101.     jb    init_2b
  102.     cmp    [si+4],dx
  103.     jb    init_2b
  104.     ; got a big enough one!
  105.     jmp    init_2c
  106. init_2b:
  107.     cmp    si,offset init_2_tend - 6
  108.     je    init_2c
  109.     add    si,6
  110.     jmp    init_2a
  111. init_2c:
  112.     mov    ax,[si]
  113.     push    si
  114.     int    10h
  115.     pop    si
  116.     mov    cx,[si+2]
  117.     mov    dx,[si+4]
  118.     ret
  119.  
  120. init_3: ; biggest text
  121.     mov    ax,[init_2_tend-6]
  122.     int    10h
  123.     mov    cx,[init_2_tend-4]
  124.     mov    dx,[init_2_tend-2]
  125.     ret
  126.  
  127. init_4: ; 320x200 graphics
  128.     mov    ax,13h
  129.     int    10h
  130.     mov    cx,320
  131.     mov    dx,200
  132.     ret
  133.  
  134. init_5: ; default graphics - should be 640x480 if supported
  135.     mov    cx,def_gw
  136.     mov    dx,def_gh
  137.     jmp    init_6
  138.  
  139. init_6_table    label    word
  140.     dw    13h, 320, 200
  141.     dw     61h, 640, 400
  142.     dw     62h, 640, 480
  143.     dw     63h, 800, 600
  144. init_6_tend    label    word
  145.  
  146. init_6: ; CX*DX graphics
  147.     mov    si,offset init_6_table
  148. init_6a:
  149.     cmp    [si+2],cx
  150.     jb    init_6b
  151.     cmp    [si+4],dx
  152.     jb    init_6b
  153.     ; got a big enough one!
  154.     jmp    init_6c
  155. init_6b:
  156.     cmp    si,offset init_6_tend - 6
  157.     je    init_6c
  158.     add    si,6
  159.     jmp    init_6a
  160. init_6c:
  161.     mov    ax,[si]
  162.     push    si
  163.     int    10h
  164.     pop    si
  165.     mov    cx,[si+2]
  166.     mov    dx,[si+4]
  167.  
  168.     push    ax
  169.     push    dx
  170.     mov     dx,01ceh   ; ATI register : ensure that separed R/W is enable
  171.     mov    al,0beh    ; Register 2
  172.     out     dx,al
  173.     inc     dx
  174.     in      al,dx
  175.     dec    dx
  176.     mov        ah,al
  177.     or        ah,008h    ; set R/W enable
  178.     mov     al,0beh
  179.     out     dx,ax
  180.     pop     dx
  181.     pop     ax
  182.  
  183.     ret
  184.  
  185. init_7: ; biggest non-interlaced graphics
  186.     mov     ax,63h
  187.     int    10h
  188.     mov     cx,800
  189.     mov     dx,600
  190.  
  191.     push    ax
  192.     push    dx
  193.     mov     dx,01ceh   ; ATI register : ensure that separed R/W is enable
  194.     mov    al,0beh    ; Register 2
  195.     out     dx,al
  196.     inc     dx
  197.     in      al,dx
  198.     dec    dx
  199.     mov        ah,al
  200.     or        ah,008h    ; set R/W enable
  201.     mov     al,0beh
  202.     out     dx,ax
  203.     pop     dx
  204.     pop     ax
  205.  
  206.     ret
  207.  
  208. init_8: ; biggest graphics
  209.     mov     ax,63h
  210.     int    10h
  211.     mov     cx,800
  212.     mov     dx,600
  213.  
  214.     push    ax
  215.     push    dx
  216.     mov     dx,01ceh   ; ATI register : ensure that separed R/W is enable
  217.     mov    al,0beh    ; Register 2
  218.     out     dx,al
  219.     inc     dx
  220.     in      al,dx
  221.     dec    dx
  222.     mov        ah,al
  223.     or        ah,008h    ; set R/W enable
  224.     mov     al,0beh
  225.     out     dx,ax
  226.     pop     dx
  227.     pop     ax
  228.  
  229.     ret
  230.  
  231. init_routine    endp
  232.  
  233. ;--------------------------------------------------------------------------
  234. ; Entry: AH=read page
  235. ;        AL=write page
  236. ;
  237. ; NOTE: This runs in protected mode!  Don't mess with the segment registers!
  238. ; This code must be relocatable and may not reference any data!
  239. ;
  240. ; Exit: VGA configured.
  241. ;       AX,BX,CX,DX,SI,DI may be trashed
  242. ;
  243. ; Source: Advanced Programmer's Guide To SuperVGAs
  244. ;
  245.  
  246.     assume    ds:nothing, es:nothing
  247.  
  248. paging_routine    proc    FAR
  249.  
  250.     and     ah,07h          ; Read-plane on bits 7-6-5
  251.     ror     ah,1
  252.     ror     ah,1
  253.     ror     ah,1
  254.  
  255.     and     al,07h       ; Write-plane on bits 3-2-1
  256.     shl     al,1
  257.  
  258.     or      ah,al           ; Combine Read and Write plane
  259.  
  260.     mov     dx,01ceh       ; ATI register
  261.     mov     al,0b2h         ; plane select
  262.     out     dx,ax
  263.     ret
  264. paging_routine    endp
  265.  
  266. cseg    ends
  267.     end
  268.